import axios from "axios";
const baseUrl = serverUrl;

// 配置请求或者响应
// const service = axios.create({
// 	baseURL: serverUrl as any,
// 	timeout: 60000,
// 	headers: { 'Content-Type': 'application/json;charset=UTF-8' }
// })
// service.interceptors.request.use()
// service.interceptors.response.use()
// export default service

const get = (url: String, data: any) => {
  return new Promise((resolve, reject) => {
    axios
      .get(baseUrl + url, {
        params: data,
      })
      .then(response => {
        resolve(response.data);
      })
      .catch(err => {
        reject(err);
      });
  });
};
const post = (url: String, data: any) => {
  return new Promise((resolve, reject) => {
    axios
      .post(baseUrl + url, data)
      .then(response => {
        resolve(response.data);
      })
      .catch(err => {
        reject(err);
      });
  });
};
export default {
  get,
  post,
};
